$("#changePasswordBtn").click(function(){
    var oldPass = $("#oldPasswordInput").val();
    var newPass = $("#newPasswordInput").val();
    var confirmPass = $("#confirmPasswordInput").val();
    if(newPass == confirmPass){
        $.ajax({
            type: "POST",
            contentType: "application/x-www-form-urlencoded",
            dataType: "json",
            url: "${baseURL}/user/updatePassword",
            data:{"oldPass":oldPass,"newPass":newPass},
            async: false,
            success:function(data){
                if(data.code === 0){
                    swal({
                        title: "操作成功。",
                        type: "success"
                    },function(){
                        location.reload();
                    })
                }
            },
            error:function(xhr, status, error){
                console.log(xhr.responseText);
                swal({
                    title: "网络错误。",
                    type: "error"
                })
            }
        });
    }else{
        swal({
            title: "两次输入的密码不一样！",
            type: "error"
        })
    }
});

$("#pictureBtn").click(function(){
    if($("#pictureInput").val() == ""){
        swal({
            title: "没有选择头像图片。",
            type: "error"
        })
    }else{
        var form = new FormData(document.forms.namedItem("pictureForm"));
        $.ajax({
            type: "POST",
            cache: false,
            contentType:false,
            processData:false,
            url:"${baseURL}/user/updatePicture",
            data:form,
            success:function(data){
                if(data.code === 0){
                    swal({
                        title: "操作成功。",
                        type: "success"
                    },function(){
                        location.reload();
                    })
                }
            },
            error:function(xhr, status, error){
                console.log(xhr.responseText);
                swal({
                    title: "网络错误。",
                    type: "error"
                })
            }

        });
    }
});